﻿namespace ECG.Common
{
    public static class ViewProductDetailDto_ExMethod
    {
        public static decimal GetPricePromotionBySizePrice(this ViewProductDetailDto item, decimal sizePrice)
        {
            decimal price = 0;
            if(item.UsePercentage)
            {
                if (item.PromotionPrice > 0)
                {
                    price = sizePrice - (sizePrice * item.DiscountPercentage) / 100;
                }
            }            
            else
            {
                if (item.PromotionPrice > 0)
                {
                    price = sizePrice - item.DiscountAmount;
                }
            }
            return price;
        }
    }
}
